package com.cup.common.encryption;

import java.security.MessageDigest;

public class MD5Utils {
	
	public static String md5(String data) throws Exception{
		MessageDigest md5 = MessageDigest.getInstance("MD5");
		md5.update((data).getBytes("utf-8"));
		
		byte encrypt[] = md5.digest();
		
		StringBuilder sb = new StringBuilder();
        for (byte t : encrypt) {
        	String s = Integer.toHexString(t & 0xFF);
        	if (s.length() == 1) {
        	    s = "0" + s;
        	}
            sb.append(s);
        }
		return sb.toString();
	}
}
